<template>
    <h3>我是子组件</h3>
    <div>
        <input v-model="a" placeholder="请输入"/>
        <button @click="handleAdd" type="button">添加</button>
    </div>
</template>
<script setup>
import { ref, defineEmits, defineProps } from 'vue'
const a = ref('')
const props = defineProps({
  list: {
    type: Array,
    default: () => [],
  },
})
const emits = defineEmits(['update:list'])
// 添加操作
const handleAdd = () => {
  const arr = props.list
  arr.push(a.value)
  emits('update:list', arr)
  a.value = ''
}
</script>